<?php
/**
 * Demo special for form_check.php
 */
class A {
    static function foo($v) {
        return array(TRUE, 'pp'.$v.'qq');
    }
}
include_once 'form_check.php';
//include_once 'D:\learn\source\php\phar\form_check.phar';
$input_format = array(
    'name' => FC_chs('名称')->min(1)->max(3)->required(),
    'telphone' => FC_phone('固定电话'),
    'mobile' => FC_mobile('手机'),
    'ip' => FC_ip('用户ip')->required(),
    'even_number' => FC_int('序号')->min(1)
        ->callback(
            array('A', 'foo')
            /*
            function($v) {
                return array($v % 2 === 0, $v);
            }
             */
        )->msg('{{ name }}必须是大于0的整数'),
    'email' => FC_email('邮件')->required(),
    'begin_date' => FC_date('开始时间', 'Y-m-d H:i'),
    'end_date' => FC_date('开始时间'),
    'page' => FC_int('页码', 1)
);


$source = array(
    'name' => '张三',
    'mobile' => '13888888888',
    'ip' => '192.168.1.1',
    'even_number' => '321',
    'email' => '11@163.com',
    'begin_date' => '2011/7/22 15:32:33',
    'end_date' => '2011-8-22 15:32:33',
);

$checker = new Form_checker($source, $input_format);

if($checker->check($source, $input_format)) {
    var_dump($checker->get_valid_data());
} else {
    var_dump($checker->get_error_message());
}


/* End of file demo.php */
